package org.linlinjava.litemall.db.service;

import com.github.pagehelper.PageHelper;
import org.linlinjava.litemall.db.dao.TaskOrderCommissionMapper;
import org.linlinjava.litemall.db.domain.TaskOrderCommission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by 75720 on 2019/05/20.
 */
@Component
public class TaskOrderCommissionService {
    @Autowired
    private TaskOrderCommissionMapper taskOrderCommissionMapper;

    public boolean saveTask(TaskOrderCommission orderCommission) {
        return taskOrderCommissionMapper.saveTask(orderCommission);
    }

    public boolean updateTask(TaskOrderCommission orderCommission) {
        return taskOrderCommissionMapper.updateTask(orderCommission);
    }

    public List<TaskOrderCommission> queryList(TaskOrderCommission orderCommissionTask, Integer page, Integer limit, String sort, String order) {
        if(page != null && limit != null) {
            PageHelper.startPage(page, limit);
        }
        StringBuffer orderby = new StringBuffer("");
        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
            orderby.append(sort + " " + order);
        }
        return taskOrderCommissionMapper.queryList(orderCommissionTask, orderby.toString());
    }


    public List<TaskOrderCommission> queryOrderList(Map<String, Object> params, String sort, String order) {
        StringBuffer orderby = new StringBuffer("");
        if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
            orderby.append(sort + " " + order);
        }
        return taskOrderCommissionMapper.queryOrderList(params, orderby.toString());
    }
}
